/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package BLO;

import DAO.UserDAO;
import DTO.UserDTO;
import Util.ConnectionUtil;
import java.sql.Connection;
import java.util.ArrayList;

/**
 *
 * @author Arturia
 */
public class UserBLO {
    private Connection con;
    public UserDTO checkLogin(String username, String password){
        ArrayList<UserDTO> list = new ArrayList<UserDTO>();
        try{
            con = ConnectionUtil.getConnection();
            list = UserDAO.LoadDatabase(con, null);

            for(int i = 0; i < list.size(); i++){
                if(list.get(i).getStrUsername().equals(username) &&
                        list.get(i).getStrPassword().equals(password)){
                    return UserDAO.checkUserRole(con, list.get(i));
                }
            }
        }catch(Exception e){
            e.printStackTrace();
        }
        return null;
    }

}
